//
//  MyViewController.m
//  chongwu
//
//  Created by 隼目 on 2021/9/15.
//

#import "MyViewController.h"
#import "MyTableViewCell.h"
#import "PersonalInformationViewController.h"
#import "AddressBookViewController.h"
#import "MyPetViewController.h"
@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource,myDelegate>
@property(nonatomic,strong)BaseTableView *tableView;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.rightBarButton.hidden=NO;
    [self.rightBarButton setImage:[UIImage imageNamed:@"shezhi"] forState:0];
    [self.rightBarButton addTarget:self action:@selector(pusViewController) forControlEvents:UIControlEventTouchUpInside];
    
    self.tableView=[BaseTableView new];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(84);
        make.bottom.mas_equalTo(-TAB_BAR_HEIGHT);
    }];
    self.tableView.backgroundColor=[UIColor clearColor];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden=YES;
}
-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBarHidden=NO;
}
-(void)pusViewController{
    NSLog(@"1345");
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MyTableViewCell *cell=[[MyTableViewCell alloc]init];
    cell.delegate=self;
    if (indexPath.row==0) {
        [cell creatUserView];
    }else if (indexPath.row==1) {
        [cell creatCenterView];
    }else if (indexPath.row==2) {
        [cell creatCellView];
    }else if (indexPath.row==3) {
        [cell creatCellView2];
    }else if (indexPath.row==4) {
        [cell creatCellView3];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return  cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

   
    if (indexPath.row==0) {
        return 192*_mainHeight;
    }else if (indexPath.row==1) {
        return 258*_mainHeight;
    }else if (indexPath.row==2) {
        return 239*_mainHeight;
    }else if (indexPath.row==3) {
        return 239*_mainHeight;
    }else if (indexPath.row==4) {
        return 239*_mainHeight;
    }
    return 0;
}

-(void)pushToPersonalInformation{
    PersonalInformationViewController *vc=[[PersonalInformationViewController alloc] init];
    vc.isHidenDog=YES;
    [ZQTools pushRootViewController:self andNextController:vc];
}
-(void)pushToMoreView:(NSInteger)index{
    if (index==3) {
        AddressBookViewController *vc=[[AddressBookViewController alloc] init];
        vc.isHidenDog=NO;
        [ZQTools pushRootViewController:self andNextController:vc];
    }else if (index==4) {
        MyPetViewController *vc=[[MyPetViewController alloc] init];
        vc.isHidenDog=NO;
        [ZQTools pushRootViewController:self andNextController:vc];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
